package Chapter6.dao;

import org.hibernate.HibernateException;

import Chapter6.entity.Customer;

import learnning.dao.base.HibernateDao;

public class CustomerDao extends HibernateDao {
	public void add(long id, String name, String address, Double age) {
		try {
			begin();
			Customer customer = new Customer(name, address, age);
			customer.setId(id);
			getSession().save(customer);
			commit();
		} catch (HibernateException e) {
			rollback();
			e.printStackTrace();
		}
	}

	public void update(long id, Double age) {
		try {
			begin();
			Customer customer = (Customer) getSession().get(Customer.class, id);
			customer.setAge(age);
			commit();
		} catch (HibernateException e) {
			rollback();
			e.printStackTrace();
		}
	}
}
